###############################################################################
## Tucan Project
##
## Copyright (C) 2008-2010 Fran Lupion crak@tucaneando.com
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
###############################################################################

import pygtk
pygtk.require('2.0')
import gtk

import pango

FEATHER = ["255 82 2 1",
" 	c None",
".	c #FFFFFF",
"                                                                                                                               ...................                                                                                                             ",
"                                                                                                                               ...................                                                                                                             ",
"                                                                                                                              ....................                                                                                                             ",
"                                                                   ..........................                  .....................................................                                                                                           ",
"                                                                  ............................                .......................................................                                                                                          ",
"                                                                  ............................                ........................................................                                                                                         ",
"                                             ................................................................................................................................                                                                                  ",
"                                            .................................................................................................................................                                                                                  ",
"                                            ..................................................................................................................................                                                                                 ",
"                                  ...................................................................................................................................................    .......                                                               ",
"                                 .....................................................................................................................................................  .........                                                              ",
"                                .................................................................................................................................................................. .....                                                       ",
"                               ..........................................................................................................................................................................                                                      ",
"                              ...........................................................................................................................................................................                                                      ",
"               .       ......................................................................................................................................................................................                                                  ",
"              ...     ........................................................................................................................................................................................                                                 ",
"              ....    .........................................................................................................................................................................................                                                ",
"         .......................................................................................................................................................................................................       ....                                    ",
"         ........................................................................................................................................................................................................     ......                                   ",
"        ..........................................................................................................................................................................................................   ........                                  ",
"      ...........................................................................................................................................................................................................................                              ",
"      ............................................................................................................................................................................................................................                             ",
"    ...............................................................................................................................................................................................................................                            ",
"   .................................................................................................................................................................................................................................                           ",
"   ..................................................................................................................................................................................................................................                          ",
"......................................................................................................................................................................................................................................                         ",
".......................................................................................................................................................................................................................................                        ",
"........................................................................................................................................................................................................................................                       ",
"...............................................................................................................................................................................................................................................................",
" ..............................................................................................................................................................................................................................................................",
"  .............................................................................................................................................................................................................................................................",
"   ............................................................................................................................................................................................................................................................",
"   ............................................................................................................................................................................................................................................................",
"   ............................................................................................................................................................................................................................................................",
"   ............................................................................................................................................................................................................................................................",
"    ...........................................................................................................................................................................................................................................................",
"     ..........................................................................................................................................................................................................................................................",
"      .........................................................................................................................................................................................................................................................",
"       ........................................................................................................................................................................................................................................................",
"        .......................................................................................................................................................................................................................................................",
"         ......................................................................................................................................................................................................................................................",
"          .. ............................................................................................................................................................................................................................................  ....",
"              .........................................................................................................................................................................................................................................        ",
"              .........................................................................................................................................................................................................................................        ",
"              ..........................................................................................................................................................................................................................                       ",
"              .........................................................................................................................................................................................................................                        ",
"               .......................................................................................................................................................................................................................                         ",
"                .....................................................................................................................................................................................................................                          ",
"                 ...................................................................................................................................................................................................................                           ",
"                 ..................................................................................................................................................................................................................                            ",
"                 .................................................................................................................................................................................................................                             ",
"                 ................................................................................................................................................................................................................                              ",
"                  ...............................................................................................................................................................................................................                              ",
"                    .............................................................................................................................................................................................................                              ",
"                    .............................................................................................................................................................................................................                              ",
"                      .........................................................................................................................................................................................................                                ",
"                      .........................................................................................................................................................................................................                                ",
"                       ........................................................................................................................................................................................................                                ",
"                         ......................................................................................................................................................................................................                                ",
"                         ......................................................................................................................................................................................................                                ",
"                          ....................................................................................................................................................................................................                                 ",
"                                    .....................................................................................................................................................................................                                      ",
"                                    .....................................................................................................................................................................................                                      ",
"                                      ...................................................................................................................................................................................                                      ",
"                                       ..................................................................................................................................................................................                                      ",
"                                       ..................................................................................................................................................................................                                      ",
"                                            ...........................................................................................................................................................................                                        ",
"                                            ..........................................................................................................................................................................                                         ",
"                                             .........................................................................................................................................................................                                         ",
"                                                                  ...............................................................................................................................................                                              ",
"                                                                  ...............................................................................................................................................                                              ",
"                                                                   ............................. ...............................................................................................................                                               ",
"                                                                                                   .........................................................................................................                                                   ",
"                                                                                                   ........................................................................................................                                                    ",
"                                                                                                                ...............  ......................................................................                                                        ",
"                                                                                                                 ..............  .....................................................................                                                         ",
"                                                                                                                 .............    ...................................................................                                                          ",
"                                                                                                                 .........       ............................  ............................                                                                    ",
"                                                                                                                 ........        ............................   ...........................                                                                    ",
"                                                                                                                  ......          ..........................    ..........................                                                                     ",
"                                                                                                                                                                     ......                                                                                    ",
"                                                                                                                                                                     .....                                                                                     "]

class FeatherWindow(gtk.Window):
	""""""
	def __init__(self):
		""""""
		gtk.Window.__init__(self, gtk.WINDOW_POPUP)
		#self.set_transient_for(parent)

		self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#000"))
		vbox = gtk.VBox()
		self.add(vbox)

		self.plugin = gtk.Label()
		self.time = gtk.Label()

		vbox.pack_start(gtk.Label(), False)
		vbox.pack_start(self.plugin, False, False, 5)
		vbox.pack_start(self.time, False, False, 5)
		self.connect('size-allocate', self._on_size_allocate)

	def _on_size_allocate(self, window, allocation):
		""""""
		pixmap, bitmap = gtk.gdk.pixmap_create_from_xpm_d(self.get_root_window(), None, FEATHER)
		width, height = pixmap.get_size()
		self.set_size_request(width, height)
		window.shape_combine_mask(bitmap, 0, 0)

	def show_feather(self, widget, event, plugin, time):
		""""""
		self.plugin.set_markup("<span foreground='#FFFFFF' weight='bold' size='medium'>" + plugin + "</span>")
		self.time.set_markup("<span foreground='#FFFFFF' weight='bold' size='small'>" + time + "</span>")
		feather_width, feather_height = self.size_request()
		win_x, win_y = widget.parent.get_parent_window().get_position()
		rect = widget.get_allocation()
		self.move(win_x + rect.x - feather_width, win_y + rect.y - 20)
		self.show_all()

	def hide_feather(self, widget, event=None):
		""""""
		self.hide()

if __name__ == "__main__":
	w = FeatherWindow()
	w.show_all()
	gtk.main()
